package menuBranch;
import java.awt.*;
import javax.swing.JFrame;


// Project: 

/******************************************************************************
 * <p>
 * File: SimlpeScreenManager.java
 * </p>
 * @author  Tadhg O'Sullivan, rogue
 * @author <a href="mailto:tadhg.osullivan@ucdconnect.ie">tadhg.osullivan@ucdconnect.ie</a>
 * @version 1.0, 2007
 * @created Jan 3, 2007 1:13:42 PM
 * @revised 
 * <p>
 * Description: Interface to change the display to full-screen mode
 * </p>
 *****************************************************************************/

public class SimlpeScreenManager {
	
	private GraphicsDevice device;
	
	/**
	 * Create a new SimpleScreenManager object
	 */
	public SimlpeScreenManager(){
		GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
		device = environment.getDefaultScreenDevice();
	}
	
	/**
	 * Enters full-screen mode and changes the display mode
	 */
	public void setFullScreen(DisplayMode displayMode, JFrame window){
		window.setUndecorated(true);
		window.setResizable(false);
		
		device.setFullScreenWindow(window);
		if (displayMode != null && device.isDisplayChangeSupported()) {
			try {
				device.setDisplayMode(displayMode);
			} catch (IllegalArgumentException e) {
				// ignore - illegal mode for this device
			}
		}
	}
	
	/**
	 * Returns the window currently used in full screen mode
	 */
	public Window getFullScreenWindow(){
		return device.getFullScreenWindow();
	}
	
	/**
	 * Restores the screen's display mode
	 */
	public void restoreScreen(){
		Window window = device.getFullScreenWindow();
		if(window != null){
			window.dispose();
		}
		device.setFullScreenWindow(null);
	}
} // end of SimpleScreenManager()
